package cn.itsource.pethome.utils;

import lombok.Data;

/**
 * @Author:R
 * @Date:2022/12/31 15:06
 * Description
 */
//封装返回数据  链式编程
@Data
public class AjaxResult {
    private String msg;
    private Boolean success;
    private Long total;
    private Object data;    //返回的数据

    private AjaxResult(){
    }

    private AjaxResult(Boolean success,String msg){
        this.success = success;
        this.msg = msg;
    }

    public static AjaxResult success(){
        return new AjaxResult(true,"成功");
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public static AjaxResult error(){
        return new AjaxResult(false,"失败");
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }


    public AjaxResult setTotal(Long total) {
        this.total = total;
        return this;
    }

    public AjaxResult setData(Object data) {
        this.data = data;
        return this;
    }
}
